package lab02.test16;
//对象之间的转换分为向上转型和向下转型两种情况
//上转型是指将子类类型的引用赋值给父类或祖先类型的引用，
//赋值操作中包含了隐式的类型转换
public class Test16 {
    public static void main(String[] args) {
        Arithmetic a;
        Addition add = new Addition();
        a = add;//对象a是子类对象add的上转型对象
        System.out.println( "加法计算得："+a.arithmetic(7,6));

        Arithmetic b;
        Substraction s = new Substraction();
         b = s ;//对象b是子类对象s的上转型对象
        System.out.println("减法计算得:"+b.arithmetic(64,45));

        Arithmetic c ;
        Multiplication m = new Multiplication();
        c = m;//对象c是子类对象m的上转型对象
        System.out.println("乘法计算得:"+c.arithmetic(25,32));

        Arithmetic d ;
        Division di = new Division();
        d = di;//对象d是子类对象di的上转型对象
        System.out.println("除法计算得："+d.arithmetic(366,3));
    }
}
